package Blog;

class Date{
    int year;
    int month;
    int day;

    //构造方法
    public Date(int year) {
        this.year = year;
    }

    public Date(int year, int month) {
        this.year = year;
        this.month = month;
    }

    public Date(int year, int month, int day){
        this.year = year;
        this.month = month;
        this.day = day;
    }

    public void setDay(int year,int month,int day){
        this.year = year;
        this.month = month;
        this.day = day;
    }

    public  void printDay(){
        System.out.println(year + "年" + month + "月" + day + "日");
    }
}

public class blog {
    public static void main(String[] args) {
        //调用方法 且传参进行初始化
        Date date = new Date(2024,4,29);
        date.printDay();
        System.out.println("===========================");

        //也可以使用成员属性直接赋值
//        date.year = 2024;
//        date.month = 4;
//        date.day = 29;
//        date.printDay();


        Date date1 = new Date(2023,3,30);
        date1.printDay();
    }
}
